package org.fmblzf.library.asyc;


import android.os.Handler;
import android.os.Message;

import org.fmblzf.library.inter.AsmHandleListener;

/**
 * Created by Administrator on 2016/1/20.
 */
public class AsycHandler extends Handler {

    /**
     * 接口类
     */
    private AsmHandleListener mListener = null;

    /**
     * 构造器
     * @param listener
     */
    public AsycHandler(AsmHandleListener listener) {
        this.mListener = listener;
    }

    @Override
    public void dispatchMessage(Message msg) {
//        super.dispatchMessage(msg);
        switch (msg.what){
            case  Intant.START :
                if (mListener != null){
                    mListener.start(msg.what,msg);
                }
                break;
            case Intant.PROCESS:
                if (mListener != null){
                    mListener.process(msg.what,msg);
                }
                break;
            case Intant.SUCESS:
                if (mListener != null){
                    mListener.sucess(msg.what,msg);
                }
                break;
            case Intant.FAIL:
                if (mListener != null){
                    mListener.fail(msg.what,msg);
                }
                break;
            default:
                break;
        }
    }
}
